package e.odbo.data.util;

import e.odbo.data.generator.Generator;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class MockUtils {

    public static <T> T round(List<T> baseDatas){
        if(null==baseDatas||baseDatas.isEmpty())
            return null;
        return baseDatas.get(new Random(baseDatas.size()).nextInt());
    }

    public static <T> T round(T... baseDatas){
        if(null==baseDatas||baseDatas.length==0)
            return null;
        return baseDatas[new Random(baseDatas.length).nextInt()];
    }

    public static <T> List<T> mock(int count, Generator<T> generator){
        List<T> retList=new ArrayList<>();
        if(count<0)
            count=0;
        for(int i=0;i<count;i++)
            retList.add(generator.generator());
        return retList;
    }
}
